package com.mmall.concurrency.example.singleton;

import com.mmall.concurrency.annoations.NotThreadSafe;

/**
 * 懒汉模式
 * 单例实例在第一次使用时进行创建
 */

@NotThreadSafe
public class SingletonExample1 {

    //私有构造函数
    private SingletonExample1()
    {

    }

    //单例对象
    private static SingletonExample1 singleton = null;

    // 静态的工厂方法
    public static SingletonExample1 getSingleton() {
        if(singleton == null)
        {
            singleton = new SingletonExample1();
        }
        return singleton;
    }
}
